<!DOCTYPE HTML>
<html>

	<head>
        <?php
        	$file_handle = fopen("header.txt", "r");
			
			while (!feof($file_handle)) {
   				$line = fgets($file_handle);
   				echo $line;
			}
			
			fclose($file_handle);
        ?>
                
        <script type="text/javascript">
  			var _gaq = _gaq || [];
  			_gaq.push(['_setAccount', 'UA-35894224-1']);
  			_gaq.push(['_trackPageview']);

  			(function() {
    			var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    			ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    			var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  			})();
		</script>
	</head>

<body>
<div id="main">
	
	<div id="header">
		<div id="logo">
			<div id="logo_text">
		        <?php
		        	$file_handle = fopen("logo.txt", "r");
					
					while (!feof($file_handle)) {
		   				$line = fgets($file_handle);
		   				echo $line;
					}
					
					fclose($file_handle);
		        ?>
			</div>
		</div>
		
		<div id="menubar">
			<ul id="menu">
				<!-- put class="selected" in the li tag for the selected page - to highlight which page you're on -->
				<li><a href="index.php">Home</a></li>
				<li><a href="bio.php">Bio</a></li>
				<li><a href="curriculum.php">Curriculum</a></li>
				<li><a href="experience.php">Experience</a></li>
				<li><a href="teaching.php">Teaching</a></li>
				<li><a href="publications.php">Publications</a></li>
				<li class="selected"><a href="contact.php">Contact</a></li>
			</ul>
		</div>
	</div>
	
	<div id="site_content">
		<div class="sidebar">
        	<?php
        		$file_handle = fopen("latestNews.txt", "r");
			
				while (!feof($file_handle)) {
   					$line = fgets($file_handle);
   					echo $line;
				}
			
				fclose($file_handle);
    	    ?>
		</div>


     	<div id="content">      
			<?php
				$name = $_POST['name'];
				$email = $_POST['email'];
				$subject = $_POST['subject'];
				$message = $_POST['message'];
		
				echo '<h3>Email details</h3>';
				
				echo '<p><span><h4>Name</h4></span>'.$name.'</p>';
				echo '<p><span><h4>Email Address</h4></span>'.$email.'</p>';
				echo '<p><span><h4>Subject</h4></span>'.$subject.'</p>';
				//to make sure each line does not exceed 95 characters
				$message = wordwrap($message, 95);
				echo '<p><span><h4>Message</h4></span>'.$message.'</p>';
				
				
				$to = 'hernanimax@gmail.com';
				$subject = '[Personal Page] '.$subject;
				$msg .= 'Nome:  '.$name.' ';
				$msg .= 'Email: '.$email.' ';
				$msg .= 'Subject: '.$message;
				
				//to make sure each line does not exceed 70 characters
				$msg = wordwrap($msg, 70);
				
				
				//mail($to, $subject, $msg, 'From: ' .$email);
				
				if (mail($to, $subject, $msg, 'From: ' .$email)) {
					echo("<br /><br /><h2>Message successfully sent!</h2>");
				} else {
					echo("<br /><br /><h2>Message delivery failed... Try later.</h2>");
				}
			?>
      	</div>
	</div>


	<div id="content_footer"></div>
	<div id="footer">
        <?php
        	$file_handle = fopen("footer.txt", "r");
			
			while (!feof($file_handle)) {
   				$line = fgets($file_handle);
   				echo $line;
			}
			
			fclose($file_handle);
        ?>
	</div>
</div>
</body>
</html>
